<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/jsp/common/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>角色管理</title>
	<%@ include file="/jsp/common/meta.jsp" %>
	<link href="${ctx}/resources/css/yui.css" type="text/css" rel="stylesheet"/>
	<link href="${ctx}/resources/css/style.css" type="text/css" rel="stylesheet"/>
	<link href="${ctx}/resources/js/validate/jquery.validate.css" type="text/css" rel="stylesheet"/>
	<script src="${ctx}/resources/js/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/resources/js/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/resources/js/validate/messages_cn.js" type="text/javascript"></script>

	<script>
		$(document).ready(function() {
			//聚焦第一个输入框
			$("#name").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate();
		});
	</script>
</head>

<body>
<div id="doc3">
<%@ include file="/jsp/common/header.jsp" %>
<div id="bd">
	<div id="yui-main">
	<div class="yui-b">
	<h2>
		<c:choose>
			<c:when test="${role.id == null}">
				<c:url var="actionUrl" value="/role/new" />创建
			</c:when>
			<c:otherwise>
				<c:url var="actionUrl" value="/role/${role.id}" />修改
			</c:otherwise>
		</c:choose>角色
	</h2>
	<form:form action="${actionUrl}" commandName="role" method="post">
		<form:hidden path="id" />
		<c:if test="${role.id != null}"><input type="hidden" name="_method" value="put"/></c:if>
		<table class="noborder">
			<tr>
				<td>角色名:</td>
				<td><input type="text" id="name" name="name" size="40" value="${role.name}" class="required"/></td>
			</tr>
			<tr>
				<td>授权:</td>
				<td>
					<c:forEach items="${optionalAuthorities}" var="item" >
       					 <input type="checkbox" name="checkedAuthorityIds" value="${item.id}"
            				<c:if test="${item.selected}">checked</c:if>/> ${item.name}
   					</c:forEach>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input class="button" type="submit" value="提交"/>&nbsp;
					<input class="button" type="button" value="返回" onclick="history.back()"/>
				</td>
			</tr>
		</table>
	</form:form>
	</div>
	</div>
</div>
<%@ include file="/jsp/common/footer.jsp" %>
</div>
</body>
</html>
